class Solution
{
public:
    vector<int> leftRigthDifference(vector<int> &nums)
    {
        int n = nums.size();
        vector<int> leftSum(n, 0);
        int sum = nums[0];
        for (int i = 1; i < n; ++i)
        {
            leftSum[i] = leftSum[i - 1] + nums[i - 1];
            sum += nums[i];
        }
        vector<int> answer(n);
        for (int i = 0; i < n; ++i)
        {
            answer[i] = abs(sum - 2 * leftSum[i] - nums[i]);
        }
        return answer;
    }
};